package com.yuliang.ai.controller;

import com.yuliang.ai.domain.Dto.UserChatInfoDto;
import com.yuliang.ai.domain.Vo.UserChatInfoVo;
import com.yuliang.ai.service.UserChatInfoService;
import com.yuliang.utils.result.ResultUtils;
import com.yuliang.utils.result.emums.HttpCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Huangkai
 */
@Slf4j
@RestController
@RequestMapping("/userChatInfo")
public class UserChatInfoController {

    @Autowired
    UserChatInfoService userChatInfoService;

    @GetMapping("/getUserChatInfoList")
    public String getUserChatInfoList() {
        List<UserChatInfoDto> userChatInfoDtoList = userChatInfoService.getUserChatInfoList();
        if(userChatInfoDtoList != null){
            return ResultUtils.ResultWithMessageDataEnum(HttpCodeEnum.select_success, userChatInfoDtoList);
        }
        return ResultUtils.ResultWithMessageEnum(HttpCodeEnum.data_not_exist);
    }

    @PostMapping("/insertUserChatInfo")
    public String insertUserChatInfo(@RequestBody UserChatInfoVo userChatInfoVo) {
        return userChatInfoService.insertUserChatInfo(userChatInfoVo);
    }

    @PostMapping("/getUserChatInfo")
    public String getUserChatInfoDto(@RequestBody List<String> humanIdentifyIdList) {
        if(humanIdentifyIdList == null || humanIdentifyIdList.size() <= 0){
            return ResultUtils.ResultWithMessageEnum(HttpCodeEnum.data_not_exist);
        }
        List<UserChatInfoDto> userChatInfoDtoList = userChatInfoService.getUserChatInfoDto(humanIdentifyIdList);
        if(userChatInfoDtoList != null && userChatInfoDtoList.size() > 0){
            return ResultUtils.ResultWithMessageDataEnum(HttpCodeEnum.select_success, userChatInfoDtoList);
        }
        return ResultUtils.ResultWithMessageEnum(HttpCodeEnum.data_not_exist);
    }
}
